// run: $exec < input
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

int const inf = 1 << 30;
int a[200007];

int main()
{
	std::ios::sync_with_stdio(false);
	std::string s;
	int n;
	std::cin >> n >> s;
	for (int i = 1; i <= n; i++) std::cin >> a[i];
	int lastr = -1;
	int ans = 1 << 30;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') lastr = i;
		else {
			if (lastr == -1) continue;
			ans = std::min(ans, (a[i + 1] - a[lastr + 1]) / 2);
		}
	}
	if (ans >= inf) std::cout << "-1\n";
	else std::cout << ans << "\n";
}

